import java.util.Scanner;

public class demo1 {
    public static int[] playCard(int[] card, int k, int n) {
        int[] ret = card;
        for (int i = 0; i < k ; i++) {
            int[] left = new int[n];
            int[] right = new int[n];
            for (int j = 0; j < n; j++) {
                left[j] = ret[j];
            }
            for (int j = 0; j < n; j++) {
                right[j] = ret[j + n];
            }
            int index = 2 * n - 1;
            for (int j = n - 1; j >= 0; j--) {
                ret[index] = right[j];
                index--;
                ret[index] = left[j];
                index--;
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        for (int i = 0; i < num; i++) {
            int n = scan.nextInt();
            int k = scan.nextInt();
            int[] card = new  int[n * 2];
            for (int j = 0; j < card.length; j++) {
                card[j] = scan.nextInt();
            }
            int[] ret = new int[2 * n];
            ret = playCard(card, k, n);
            for (int j = 0; j < ret.length-1; j++) {
                System.out.print(ret[j] + " ");
            }
            System.out.println(ret[ret.length-1]);
        }
    }
}
